package com.kb.erp.mapper.sqlServer.kbidm;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kb.erp.entity.HrEntity;
import com.kb.erp.entity.PayAccount;
import com.kb.erp.entity.PerDepartInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PayAccountMapper extends BaseMapper<PayAccount> {

    @Select("<script>"
            + "SELECT "
            + "PerEmployee.EmpName,"
            + "PerEmployee.EmpNo AS empNumber,"
            + "PerEmployee.DutyNo,"
            + "PerEmployee.DtName,"
            + "PerEmployee.LevelLevel,"
            + "CASE "
            + "   WHEN PerEmployee.LevelClass LIKE '%[0-9]%等' THEN CAST(REPLACE(PerEmployee.LevelClass, '等', '')* 10 AS INT)"
            + "    ELSE 0 END AS LevelClass,"
            + "PerEmployee.PerField7,"
            + "SysSetList.Remark AS keyWord,"
            + "SysSetList.ItemName,"
            + "PayBankSet.MyField1 as bankCode,"
            + "PayBankSet.BName,"
            + "PayAccount.* "
            + "FROM PerEmployee "
            + "LEFT JOIN PayAccount ON PerEmployee.EmpNo = PayAccount.EmpNo "
            + "LEFT JOIN PayBankSet ON PayAccount.BNo = PayBankSet.BNo "
            + "LEFT JOIN SysSetList ON SysSetList.ItemID = PerEmployee.PerField7 "
            + "WHERE SysSetList.TypeID = 'RS996' AND PerEmployee.EmpCurrentStateNo != '04'"
            + "</script>")
    Page<PayAccount> queryBankCard(Page<PayAccount> payAccountPage);

    /**
     *
     *
     *
     *              SELECT
     *              PerEmployee.EmpName,
     *              PerEmployee.EmpNo AS empNumber,
     *              PerEmployee.DutyNo,
     *
     *
     *              SysSetList.ItemName,
     *              PayBankSet.MyField1 as bankCode,
     *              PayBankSet.BName,
     *              PayAccount.reMark
     *              FROM PerEmployee
     *              LEFT JOIN PayAccount ON PerEmployee.EmpNo = PayAccount.EmpNo
     *              LEFT JOIN PayBankSet ON PayAccount.BNo = PayBankSet.BNo
     *              LEFT JOIN SysSetList ON SysSetList.ItemID = PerEmployee.PerField7
     *              WHERE SysSetList.TypeID = 'RS996' AND PerEmployee.EmpCurrentStateNo != '04'
     *

     */
    @Select("SELECT " +
            "p.MyField1 as webChatDepartId, " +
            "p.PartName AS partName, " +
            "p.EmpNo AS empNo, " +
            "p.EmpNo2 AS empNo2, " +
            "p.EmpNo3 AS empNo3, " +
            "p.MainMan AS mainMan, " +
            "y.EmpName AS empName2, " +
            "e.EmpName AS empName3 " +
            "FROM [D1_2012_1108].[dbo].perdepart p " +
            "LEFT JOIN ( SELECT DISTINCT webChatDepartId, DepartNo FROM CorpWeChatDepart ) c ON c.DepartNo = p.PartNo " +
            "LEFT JOIN PerEmployee y ON y.EmpNo = p.EmpNo2 " +
            "LEFT JOIN PerEmployee e ON e.EmpNo = p.EmpNo3 " +
            "WHERE p.iscancel= 0 and p.MyField1 is not null")
    Page<PerDepartInfo> queryPerDepartInfo(Page<PerDepartInfo> perDepartInfoPage);


}
